package Sort;

import java.util.Arrays;

public class ShellSort {
    public static void main(String[] args) {
        int[] arr = {1,10,7,4,8,3,2,6,9,5};
        shell(arr);
        System.out.println(Arrays.toString(arr));
    }
    public static void shell(int[] arr) {
        int size = arr.length;
        for (int gap = size >> 1;gap >= 1; gap >>= 1) {
            for (int i = gap; i < size;i++) {
                int key = arr[i];
                int j = i-gap;
                while(j >= 0 && arr[j] > key) {
                    arr[j+gap] = arr[j];
                    j -= gap;
                }
                arr[j + gap] = key;
            }
        }
    }

}
